/*
 * Copyright (C), 2010-2017, ATCOM Tech. Co., Ltd.
 *
 * File Name: threadlog.h
 * Author: liaoxuecheng
 * mail: 872958436@qq.com
 * Created Time: Thu 03 Sep 2020 10:03:49 AM CST
 *
 */

#ifndef _THREADLOG_H_
#define _THREADLOG_H_

#include <syslog.h>

#define THREAD_TERMLOG 0
#define THREAD_SYSLOG  1

extern int threadpool_log(int priority, const char *format, ...);
extern int threadpool_log_init(const char *name, int type, int level);
extern int threadpool_log_set_level(int level);
extern int threadpool_log_deinit();

#define COLOR_RED "\033[31;1m"
#define COLOR_GREEN "\033[32;1m"
#define COLOR_YELLOW "\033[33;1m"
#define COLOR_NONE "\033[0m\n"

#define DEBUG_ERROR(title,fmt,arg...) threadpool_log(LOG_ERR, "%s [%s:%d] " COLOR_RED fmt COLOR_NONE, \
        title, __func__, __LINE__, ##arg)
#define DEBUG_WARN(title,fmt,arg...) threadpool_log(LOG_WARNING, "%s [%s:%d] " COLOR_YELLOW fmt COLOR_NONE, \
        title, __func__, __LINE__, ##arg)
#define DEBUG_NOTICE(title,fmt,arg...) threadpool_log(LOG_NOTICE, "%s [%s:%d] " COLOR_GREEN fmt COLOR_NONE, \
        title, __func__, __LINE__, ##arg)
#define DEBUG_INFO(title,fmt,arg...) threadpool_log(LOG_INFO, "%s [%s:%d] " "\033[35;1m" fmt "\033[0m\n", \
        title, __func__, __LINE__, ##arg)
#define DEBUG_MSG(title,fmt,arg...) threadpool_log(LOG_DEBUG, "%s [%s:%d] " fmt , \
        title, __func__, __LINE__, ##arg)

#endif //_THREADLOG_H_
